/*
 * Copyright (c) 2008-2013 Haulmont. All rights reserved.
 * Use is subject to license terms, see http://www.cuba-platform.com/license for details.
 */

package com.haulmont.asu.web.ui.person;

import com.haulmont.cuba.gui.components.AbstractLookup;
import com.haulmont.cuba.gui.components.IFrame;
import com.haulmont.cuba.gui.components.TabSheet;

import javax.inject.Inject;
import java.util.Map;

/**
 * Author: Sergey42
 * Date: 10.11.13 4:31
 */
public class PersonLookup extends AbstractLookup {

    @Inject
    protected TabSheet tabSheet;

    @Inject
    protected IFrame employeesFrame;

    @Inject
    protected IFrame presentersFrame;

    @Override
    public void init(Map<String, Object> params) {
        tabSheet.addListener(new TabSheet.TabChangeListener() {
            @Override
            public void tabChanged(TabSheet.Tab newTab) {
                if ("institute".equals(newTab.getName())) {
                    setLookupComponent(employeesFrame.getComponent("cathedralEmployeesTable"));
                } else if ("corporation".equals(newTab.getName())) {
                    setLookupComponent(presentersFrame.getComponent("presentersTable"));
                }
            }
        });
    }


}
